package com.elitel.frame.base.service.impl;

import com.elitel.common.utils.UUIDUtil;
import com.elitel.frame.base.service.CfgExtsqlLogService;
import com.elitel.frame.main.dao.CfgExtsqlLogMapper;
import com.elitel.frame.main.entity.CfgExtsqlLog;
import com.elitel.frame.main.entity.constant.TmpUser;
import com.elitel.frame.main.entity.vo.JsonResult;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;

@Service
public class CfgExtsqlLogServiceImpl implements CfgExtsqlLogService {
    @Resource
    CfgExtsqlLogMapper cfgExtsqlLogMapper;

    @Override
    public PageInfo<CfgExtsqlLog> getList(PageInfo pageInfo, CfgExtsqlLog cfgExtsqlLog) {
        PageHelper.startPage(pageInfo.getPageNum() ,pageInfo.getPageSize());
        List<CfgExtsqlLog> list = cfgExtsqlLogMapper.getList(cfgExtsqlLog);
        return new PageInfo<>(list);
    }

    @Override
    public int insert(CfgExtsqlLog cfgExtsqlLog) {
        cfgExtsqlLog.setExtsqlLogId(UUIDUtil.randomUUID());
        cfgExtsqlLog.setCreatedTime(new Date());
        cfgExtsqlLog.setCreatedUser(TmpUser.ADMIN);
        return cfgExtsqlLogMapper.insertSelective(cfgExtsqlLog);
    }
}
